public class text {
    Node1 head;
    Node1 top;
    int N;
    public text(){
        top=null;
        head=new Node1(null);
        N=0;
    }
    public void add(Object x){
        Node1 temp =head;
        while (temp.next!=null){
            temp=temp.next;
        }
        Node1 node1 = new Node1(x);
        temp.next=node1;
        N++;
    }
    public void print(){
        Node1 node1 = new Node1(null);
        node1=head.next;
        for (int i = 0; i < N; i++) {
            System.out.print(node1.data+"\t");
            node1=node1.next;
        }
    }
    public void reverse(){
        Node1 a=head.next;
        head.next=a.next;
        a.next=top;
        top=a;
    }

    public static void main(String[] args) {
        text text = new text();
        text.add("a");
        text.add("b");
        text.add("c");
        text.print();
        System.out.println("------------");
        text.reverse();
        text.print();
    }

}
class Node1 {
    Object data;
    Node1 next;
    public Node1(Object data){
        this.data=data;
        this.next=null;
    }
}
